<template>
    <el-config-provider :locale="zhCn">
        <router-view></router-view>
    </el-config-provider>
</template>

<script lang="ts" setup>
import { onBeforeUnmount, onMounted, provide, ref } from 'vue';
import { ElConfigProvider, ElNotification } from 'element-plus';
import zhCn from 'element-plus/lib/locale/lang/zh-cn';
import { store } from '@/store/index';
import { isCachePage } from '@/utils/utils';
import * as echarts from 'echarts';
provide('ec', echarts);

/**
 * @description: 刷新页面时 如果在缓存的页面，清空缓存
 * @return {*}
 */
const clearKeepAliveViewsCache = () => {
    if (isCachePage()) {
        store.dispatch('pageCache/setKeepAliveViews', []);
    }
};

onMounted(() => {
    // 设置监听
    window.addEventListener('beforeunload', () => clearKeepAliveViewsCache());
});

onBeforeUnmount(() => {
    // 取消监听
    window.removeEventListener('beforeunload', () => clearKeepAliveViewsCache());
});
</script>

<style lang="scss">
@use './styles/parabola.scss';
@import '@/styles/reset';
@import '@/styles/common';
</style>
